import request from "./request";

const http = {
  get(url, params = {}) {
    const config = {
      method: "get",
      url: url,
      params
    };
    return new Promise((resolve) => {
      request(config).then((res) => {
        if (res) {
          resolve(res);
        }
      });
    });
  },
  post(url, data = {}) {
    const config = {
      method: "post",
      url: url,
      data
    };
    return new Promise((resolve) => {
      request(config).then((res) => {
        if (res) {
          resolve(res);
        }
      });
    });
  },
  patch(url, data = {}) {
    const config = {
      method: "patch",
      url: url,
      data
    };
    return new Promise((resolve) => {
      request(config).then((res) => {
        if (res) {
          resolve(res);
        }
      });
    });
  },
  delete(url) {
    const config = {
      method: "delete",
      url: url
    };
    return new Promise((resolve) => {
      request(config).then((res) => {
        if (res) {
          resolve(res);
        }
      });
    });
  }
};
export default http;
